<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">

<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>
<link href="${ctx.resource}/css/credit-mall.css" rel="stylesheet">
<title>我的地址</title>
</head>
<body>
	<div class="page-group">
		<div class="page page-current">
			<div class="bar bar-footer">
				<c:if test="${addressType == 'profile'}">
					<div class="add-address-tool">
						<a href="${ctx.host}/profile/addresses/create" class="add-address"> <i class="iconfont icon-icon02"></i>新增地址
						</a>
					</div>
					<div class="edit-address-tool hide">
						<div class="row no-gutter">
							<a href="javascript:void(0);" class="col-50 set-default">设为默认地址</a> <a href="javascript:void(0);" class="col-50 delete">删除</a>
						</div>
					</div>
				</c:if>

				<c:if test="${addressType == 'product'}">
					<div class="consignee-address-tool" style="margin-left: -.75rem; margin-right: -.75rem;">
						<div class="row no-gutter">
							<a href="${ctx.host}/credit-mall/products/${productId}/addresses/create" class="col-50 add-address" style="position: static;"><i class="iconfont icon-icon02"></i>新增地址</a> <a href="javascript:void(0);" class="col-50 consignee-address">选择为收件地址</a>
						</div>
					</div>
				</c:if>

			</div>

			<div class="content">

				<c:if test="${addressType == 'profile'}">
					<div class="content-block-title">
						地址管理 <a href="javascript: void(0);" class="pull-right edit-address">编辑</a>
					</div>
				</c:if>
				<c:if test="${addressType == 'product'}">
					<div class="content-block-title">地址管理</div>
				</c:if>

				<div class="list-block no-margin">
					<ul>
						<c:forEach items="${userAddresses}" var="ua">
							<li><a href="<c:if test="${addressType == 'profile' }">${ctx.host}/profile/addresses/${ua.id}/edit</c:if><c:if test="${addressType == 'product' }">${ctx.host}/credit-mall/products/${productId}/addresses/${ua.id}/edit</c:if>" class="item-content address-list">
									<div class="item-media">
										<label class="input-label"> <input type="checkbox" name="address" class="${addressType == 'product' ? '' : 'hide'}" data-address="${ua.id }">
										</label>
									</div>
									<div class="item-inner">
										<div class="items" style="font-size: .75rem; color: #303030;">
											<span class="left" style="letter-spacing: 2px;">收货人：</span>
											<p class="no-margin">${ua.contactName}${ua.contactPhone}</p>
										</div>
										<div class="items" style="font-size: .65rem; color: #737373;">
											<span class="left">收货地址：</span>
											<p class="no-margin ellipsis">${ua.province}${ua.city}${ua.region}${ua.address}</p>
										</div>
									</div>
									<div class="item-after">
										<c:if test="${ua.defaultAddress}">
											<button class='button default-button'>默认地址</button>
										</c:if>
									</div>
							</a></li>
						</c:forEach>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<%@ include file="/WEB-INF/include/script.jsp"%>
	<d:resource type="script" root="${ctx.resource}/build" src="js/page/profile/address/profile-address-list.js" />
	<script type="text/javascript">
		require([ 'page/profile/address/profile-address-list' ],
				function(page) {
					page.init({
						"addressType" : "${addressType}",
						"productId" : "${productId}",
						"defaultAddressId" : "${defaultAddress.id}"
					})
				})
	</script>
</body>
</html>